<template>
  <div class="tabBox">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane v-if="this.menuList.includes('surveyCombined')" label="平台推荐组合" name="platform">
          <platform-measurement></platform-measurement>
        </el-tab-pane>
        <el-tab-pane v-if="this.menuList.includes('surveySelfCombined')" label="自建测评组合" name="self">
          <self-measurement></self-measurement>
        </el-tab-pane>
        <el-tab-pane v-if="this.menuList.includes('surveySingle')" label="单个测评量表" name="single">
          <single-measurement></single-measurement>
        </el-tab-pane>
      </el-tabs>
    </div>
</template>
<script>
import platformMeasurement from './components/platformMeasurement'
import selfMeasurement from './components/selfMeasurement'
import singleMeasurement from './components/singleMeasurement'
export default {
  components: {
    platformMeasurement,
    selfMeasurement,
    singleMeasurement
  },
  data () {
    return {
      activeName: '',
      activeList: ['platform', 'self', 'single'],
      menuList: []
    }
  },
  created () {
    this.menuList = sessionStorage.getItem('list')
    let router = this.$router.history.current.path.substring(1)
    if (this.$cookies.get('menu') === router) {
      if (this.activeList.includes(this.$cookies.get('activeName'))) {
        this.activeName = this.$cookies.get('activeName')
      }
    }
    if (this.menuList.includes('surveyCombined')) {
      this.activeName = 'platform'
    } else if (this.menuList.includes('surveySelfCombined')) {
      this.activeName = 'self'
    } else {
      this.activeName = 'single'
    }
  },
  methods: {
    handleClick () {
      this.$cookies.set('activeName', this.activeName)
    }
  }
}
</script>
